import newRequest from '@/utils/newRequest'
import request from '@/utils/request'
import { mergeParams } from '@/utils'

// 最新代码
// 开始
// 我的申报列表
export function doMyTechQuery(query) {
  const data = mergeParams(query)
  return newRequest({
    url: '/MTSaas/xjsTech/doMyTechQuery',
    method: 'post',
    data
  })
}
// 申报删除
export function doDelete(query) {
  const data = mergeParams(query)
  return newRequest({
    url: `/MTSaas/xjsTech/doDelete`,
    method: 'delete',
    data
  })
}
// 我的草稿
export function doMyDraftQuery(query) {
  const data = mergeParams(query)
  return newRequest({
    url: '/MTSaas/xjsTech/doMyDraftQuery',
    method: 'post',
    data
  })
}
// 已开通项目
export function doOpenedProjectQuery(query) {
  const data = mergeParams(query)
  return newRequest({
    url: '/MTSaas/xjsTech/doOpenedProjectQuery',
    method: 'post',
    data
  })
}
// 待我审批的
export function doPendingApprovalQuery(query) {
  const data = mergeParams(query)
  return newRequest({
    url: '/MTSaas/xjsTech/doPendingApprovalQuery',
    method: 'post',
    data
  })
}
// 我已审批的
export function doAlreadyApprovedQuery(query) {
  const data = mergeParams(query)
  return newRequest({
    url: '/MTSaas/xjsTech/doAlreadyApprovedQuery',
    method: 'post',
    data
  })
}

// 我申请的年审
export function doMyAuditApplication(query) {
  const data = mergeParams(query)
  return newRequest({
    url: '/MTSaas/xjsYearAudit/doMyAuditApplication',
    method: 'post',
    data
  })
}

// 我申请的草稿
export function doMyDraftApplication(query) {
  const data = mergeParams(query)
  return newRequest({
    url: '/MTSaas/xjsYearAudit/doMyDraftQuery',
    method: 'post',
    data
  })
}

// 申请数据删除
export function doDeleteApplication(query) {
  const data = mergeParams(query)
  return newRequest({
    url: '/MTSaas/xjsYearAudit/doDelete',
    method: 'post',
    data
  })
}

// 已完成的年审
export function doCompletedProjectAudit(query) {
  const data = mergeParams(query)
  return newRequest({
    url: '/MTSaas/xjsYearAudit/doCompletedProjectAudit',
    method: 'post',
    data
  })
}

// 待确认审批阶段
export function doPendingStageReviewConfirmation(query) {
  const data = mergeParams(query)
  return newRequest({
    url: '/MTSaas/xjsYearAudit/doPendingStageReviewConfirmation',
    method: 'post',
    data
  })
}

// 已确认审批阶段
export function doConfirmedStageReview(query) {
  const data = mergeParams(query)
  return newRequest({
    url: '/MTSaas/xjsYearAudit/doConfirmedStageReview',
    method: 'post',
    data
  })
}

// 新技术查询列表
export function selectAllByPage(query) {
  const data = mergeParams(query)
  return newRequest({
    url: '/MTSaas/xjsTech/selectAllByPage',
    method: 'post',
    data
  })
}

// 新技术列表汇总
export function selectAllByTotal(query) {
  const data = mergeParams(query)
  return newRequest({
    url: '/MTSaas/xjsTech/selectAllByTotal',
    method: 'post',
    data
  })
}

// 项目列表
export function doQueryHisPage(query) {
  const data = mergeParams(query)
  return newRequest({
    url: '/MTSaas/XjsTechHis/doQueryPage',
    method: 'post',
    data
  })
}

// 项目删除
export function doHisDelete(query) {
  const data = mergeParams(query)
  return newRequest({
    url: '/MTSaas/XjsTechHis/doDelete',
    method: 'delete',
    data
  })
}

// 年审查询统计
export function doYearAuditTotal(query) {
  const data = mergeParams(query)
  return newRequest({
    url: '/MTSaas/xjsYearAudit/doYearAuditTotal',
    method: 'post',
    data
  })
}

// 年审查询列表
export function doYearAuditApplication(query) {
  const data = mergeParams(query)
  return newRequest({
    url: '/MTSaas/xjsYearAudit/doYearAuditApplication',
    method: 'post',
    data
  })
}

// 结束

// 流程结构
export function processStructure(params) {
  return request({
    url: '/api/v1/xjs-order/process-structure',
    method: 'get',
    params
  })
}

// 新建工单
export function createWorkOrder(data) {
  return request({
    url: '/api/v1/xjs-order/create',
    method: 'post',
    data
  })
}

// 审批
export function newDoApprove(query) {
  const data = mergeParams(query)
  return newRequest({
    url: '/MTSaas/xjsTech/doApprove',
    method: 'put',
    data
  })
}

// 历史审批
export function newWorkOrderList(query) {
  const data = mergeParams(query)
  return newRequest({
    url: '/MTSaas/ProcessInfo/doQueryAll',
    method: 'post',
    data
  })
}


// 人员查询
export function newLimitTechDocList(query) {
  const data = mergeParams(query)
  return newRequest({
    url: '/MTSaas/xjsReviewLimitTechDoc/doQueryPage',
    method: 'post',
    data
  })
}

// 新增人员
export function newLimitTechDocAdd(query) {
  const data = mergeParams(query)
  return newRequest({
    url: '/MTSaas/xjsReviewLimitTechDoc/doSave',
    method: 'post',
    data
  })
}

// 编辑人员
export function newLimitTechDocUpdate(query) {
  const data = mergeParams(query)
  return newRequest({
    url: '/MTSaas/xjsReviewLimitTechDoc/doUpdate',
    method: 'put',
    data
  })
}

// 删除人员
export function newLimitTechDocDel(query) {
  const data = mergeParams(query)
  return newRequest({
    url: '/MTSaas/xjsReviewLimitTechDoc/doDelete',
    method: 'Delete',
    data
  })
}

// 新建工单
export function newCreateWorkOrder(query) {
  const data = mergeParams(query)
  return newRequest({
    url: '/MTSaas/xjsTech/doSave',
    method: 'post',
    data
  })
}

// 提交工单
export function newDoUpdate(query) {
  const data = mergeParams(query)
  return newRequest({
    url: '/MTSaas/xjsTech/doUpdate',
    method: 'put',
    data
  })
}

export function updateWorkOrder(data) {
  return request({
    url: '/api/v1/xjs-order/update',
    method: 'post',
    data
  })
}

export function draftWorkOrder(data) {
  return request({
    url: '/api/v1/xjs-order/draft',
    method: 'post',
    data
  })
}

export function newDraftWorkOrder(query) {
  const data = mergeParams(query)
  return newRequest({
    url: '/MTSaas/xjsTech/doDetail',
    method: 'post',
    data
  })
}

// 工单列表
export function workOrderList(params) {
  params.recycling = 0
  return request({
    url: '/api/v1/xjs-order/list',
    method: 'get',
    params
  })
}

export function workOrderTodoList(params) {
  params.recycling = 0
  return request({
    url: '/api/v1/xjs-order/list',
    method: 'get',
    params
  })
}

export function recyclingList(params) {
  params.recycling = 1
  return request({
    url: '/api/v1/xjs-order/list',
    method: 'get',
    params
  })
}

export function checkWorkNo(data) {
  return request({
    url: '/api/v1/xjs-order/checkNo',
    method: 'post',
    data
  })
}

// 处理工单
export function handleWorkOrder(data) {
  return request({
    url: '/api/v1/xjs-order/handle',
    method: 'post',
    data
  })
}

// 结束工单
export function unityWorkOrder(params) {
  return request({
    url: '/api/v1/xjs-order/unity',
    method: 'get',
    params
  })
}

// 转交工单
export function inversionWorkOrder(data) {
  return request({
    url: '/api/v1/xjs-order/inversion',
    method: 'post',
    data
  })
}

// 催办工单
export function urgeWorkOrder(params) {
  return request({
    url: '/api/v1/xjs-order/urge',
    method: 'get',
    params
  })
}

export function recallWorkOrder(params) {
  return request({
    url: '/api/v1/xjs-order/recall',
    method: 'get',
    params
  })
}

// 主动接单
export function activeOrder(data, workOrderId) {
  return request({
    url: `/api/v1/xjs-order/active-order/${workOrderId}`,
    method: 'put',
    data
  })
}

// 删除工单
export function deleteWorkOrder(workOrderId) {
  return request({
    url: `/api/v1/xjs-order/delete/${workOrderId}`,
    method: 'delete'
  })
}

export function clearWorkOrder(processId) {
  return request({
    url: `/api/v1/xjs-order/clear/${processId}`,
    method: 'delete'
  })
}

export function recyclingWorkOrder(workOrderId) {
  return request({
    url: `/api/v1/xjs-order/recycling/${workOrderId}`,
    method: 'post'
  })
}

export function resumeWorkOrder(workOrderId) {
  return request({
    url: `/api/v1/xjs-order/resume/${workOrderId}`,
    method: 'post'
  })
}

// 删除工单
export function reopenWorkOrder(id) {
  return request({
    url: `/api/v1/xjs-order/reopen/${id}`,
    method: 'post'
  })
}

// 新建年审
export function newCreateYearAudit(query) {
  const data = mergeParams(query)
  return newRequest({
    url: '/MTSaas/xjsYearAudit/doSave',
    method: 'post',
    data
  })
}

// 提交年审
export function newDoYearAudit(query) {
  const data = mergeParams(query)
  return newRequest({
    url: '/MTSaas/xjsYearAudit/doUpdate',
    method: 'put',
    data
  })
}

export function newYearAuditDetail(query) {
  const data = mergeParams(query)
  return newRequest({
    url: '/MTSaas/xjsYearAudit/doDetail',
    method: 'post',
    data
  })
}

export function newYearAuditDoApprove(query) {
  const data = mergeParams(query)
  return newRequest({
    url: '/MTSaas/xjsYearAudit/doApprove',
    method: 'put',
    data
  })
}

export function newHistoryYearAudit(query) {
  const data = mergeParams(query)
  return newRequest({
    url: '/MTSaas/XjsTechHis/doSave',
    method: 'post',
    data
  })
}

export function newHistoryYearUpdate(query) {
  const data = mergeParams(query)
  return newRequest({
    url: '/MTSaas/XjsTechHis/doUpdate',
    method: 'put',
    data
  })
}

// 统计项目编号
export function selectProjectNumbera() {
  const data = mergeParams()
  return newRequest({
    url: '/MTSaas/xjsTech/selectProjectNumber',
    method: 'post'
  })
}

